<!DOCTYPE html>
<html>
<script type="text/javascript" src="static/js/jquery-1.12.4.min.js"></script>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>后台主页模块 - XzcBlogTemplate后台管理</title>
    <link rel="stylesheet" href="static/layui/css/layui.css">
    <link rel="stylesheet" type="text/css" href="static/admin/css/common.css">
    <link rel="stylesheet" type="text/css" href="static/admin/css/blogadd.css">
</head>
<body>
<div class="layui-container main">
    <div class="layui-row layui-col-space20">
        <div class="layui-col-md12">
            <p>
		        	<span class="layui-breadcrumb" style="visibility: visible;">
			          	<a href="main.html">博客管理系统</a><span lay-separator="">/</span>
			          	<a href="bloglist.html">后台首页</a><span lay-separator="">/</span>
			          	<a><cite>博文添加</cite></a>
		        	</span>
            </p>
        </div>
        <div class="layui-col-md12">
            <form class="layui-form" action="">
                <div class="layui-form-item">
                    <label class="layui-form-label">标题</label>
                    <div class="layui-input-block">
                        <input type="text" name="title" required lay-verify="required" placeholder="请输入标题"
                               autocomplete="off" class="layui-input max_width500">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">分类</label>
                    <div class="layui-input-block">
                        <select name="city" lay-verify="required">
                            <option value="" class="max_width500"></option>
                            <option value="Java基础" class="max_width500">Java基础</option>
                            <option value="数据库" class="max_width500">数据库</option>
                            <option value="JSP" class="max_width500">JSP</option>
                            <option value="框架" class="max_width500">框架</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">置顶</label>
                    <div class="layui-input-block">
                        <input id="置顶" value="true" type="checkbox" name="switch" lay-skin="switch">
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">内容</label>
                    <div class="layui-input-block">
                        <textarea name="desc" placeholder="请输入内容" class="layui-textarea" id="editor"
                                  style="height: 500px"></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <a class="layui-btn">立即提交</a>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
<script src="jquery/jquery-1.8.3.js"></script>
<script src="static/layui/layui.all.js"></script>
<script src="static/admin/javascript"></script>
<script type="text/javascript">
    /*添加功能*/
    $(document).ready(function () {
        $("[class=\"layui-btn\"]").click(function () {
            var title = $("[name=\"title\"]").val();
            var detail = $('#editor').val();
            var status = $("#置顶").prop("checked");
            if (status == true) {
                status = 1;
            } else if (status == false) {
                status = 0;
            }
            var type = $("[name='city']").val();
            var uid = localStorage.getItem("uid");
            $.get("Blog/insertBlog", {
                "title": title,
                "detail": detail,
                "type": type,
                "uid": uid,
                "status": status
            }, function (rs) {
                var er = rs.mess;
                alert(er);
                window.location.href = "http://localhost:8080/main.html";
            });
        });
    });
</script>
</html>